package com.atguigu.aiproject.tasks;

import com.atguigu.aiproject.vectorstore.CreationVectorStoreManager;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTasks {
    private final CreationVectorStoreManager creationVectorStoreManager;

    public ScheduledTasks(CreationVectorStoreManager creationVectorStoreManager) {
        this.creationVectorStoreManager = creationVectorStoreManager;
    }

    // 每次启动，将内容上传到向量数据库
    @Scheduled(initialDelay = 0, fixedDelay = 1000 * 60 * 60)
    public void loadCreationVectorStore() {
        creationVectorStoreManager.loadCreationVectorStore();
    }

    // 每天0点将所有作品重新向量化
    // @Scheduled(cron = "0 0 0 * * ?")
    public void reloadCreationVectorStore() {
        creationVectorStoreManager.reloadCreationVectorStore();
    }
}
